<script>
	import utils from "utils/utils.js"
	import store from '@/store/index'
	import { mapGetters } from 'vuex'
	export default {
		data() {
			return {
				noticeInfo: {},
				showTip: false,
				joinChannelv:false,
				msgTitle: '提示',
				tipContent: '发现火情',
				titleStyle: {},
				confirmColor: '#2979ff',
				borderTopStyle: {},
				borderTopStyleValue: {
					backgroundImage: `linear-gradient(269deg, #E74A50 0%, #FA805A 100%)`,
					borderRadius: '22.5px',
					margin: '0 20px 20px',
					fontFamily: 'PingFangSC-Medium',
					fontSize: '16px',
					letterSpacing: '0.32px'
				},
				fxhqTitleStyle: {backgroundImage: `url(../../static/img/banner3.png)`, backgroundSize: 'cover',width: '100%',height: '170px'},
				sbyjTitleStyle: {backgroundImage: `url(../../static/img/banner1.png)`, backgroundSize: 'cover',width: '100%',height: '170px'},
				sbgzTitleStyle: {backgroundImage: `url(../../static/img/banner2.png)`, backgroundSize: 'cover',width: '100%',height: '170px'},
				showMsg:false,
				noticeContent:'XX你好，今日XX时间XX建筑XX层XX区域XX位置发生火灾，请立即前往与XX协作，使用XX设备协助灭火。',
				// joinChannel:false
			}
		},
		globalData:{
			BMap: null
		},
		onLaunch: function() {
			console.log('App Launch')
			console.log("赋值token数据信息")
			store.dispatch("user/setTokenInfo").then(res=>{
				console.log("赋值token成功")
			})
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			confirm() {
				if (this.noticeInfo.audio == 'true') {
					window.native.closeAudio(9)
				}
				if(this.noticeInfo.audioOpen=='true'){
					window.native.openAudio(this.noticeInfo.audioId)
				}
				if(this.noticeInfo.audioOpen=='false'){
					window.native.closeAudio(this.noticeInfo.audioId)
				}
				this.utils.request("/api/app/notice/updateReadStatus", {ucId:this.noticeInfo.noticeInfoId}, "post", "app", true).then(res => {
					console.log(res)
				}).catch(error => {
					console.log(error)
				})
				if (this.noticeInfo.equRounds == 'true') {
					window.native.equRounds({
						title: this.noticeInfo.equipmentId,
						drill: this.noticeInfo.drill,
						ucId: this.noticeInfo.alarmInfoId,
						taskId: this.noticeInfo.taskId
					})
				}
			}
		},
		computed:{
			...mapGetters(['fireAlarm', 'notice', 'joinChannel', 'wbmessage', 'fireStop'])
		},
		watch:{
			fireAlarm: function (a, b) {
			    if (a !== b && a) {
					this.$fireAlarm.show(a).then(res=>{
					    switch (res){
					        case "enterInfo":
					            uni.navigateTo({
					                url: '/pages/index/fireInfo/info?ucId='+a.ucId
					            });
					            break;
					        default:
					            break;
					    }
					})
			    }
			},
			joinChannel: function(a, b) {
				if (a !== b && a) {
					let userInfo = JSON.parse(utils.getStorageSync("userInfo"))
					window.native.joinChannel({
					 disPlayName: userInfo.name,
					 userId: userInfo.ucId,
					 channelId: a.channel.substring(5)
					})
				}
			},
			notice: function(a, b) {
				if (a !== b && a) {
					this.$message.show(a).then(res=>{
					})
				}
			},
			wbmessage: function(a, b) {
				if (a !== b && a) {
					this.$wbmessage.show(a).then(res=>{
					})
				}
			},
			fireStop: function(a, b) {
				if (a !== b && a) {
					this.$noticemessage.show(a).then(res=>{
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "uview-ui/index.scss";
</style>

<style>
	/*每个页面公共css */
	/* 此处为style标签内容的最前面 */
	@import "./static/css/iconfont.css";
	@import "./static/css/index.css";
	@import "./static/css/main.scss";	
</style>
